package cn.edu.service.impl;

import cn.edu.dao.Col_ExamineDao;
import cn.edu.domain.All;
import cn.edu.domain.PageBean;
import cn.edu.domain.teacher;
import cn.edu.service.Col_ExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Davey chan
 */
@Service
public  class Col_ExamineServiceImpl implements Col_ExamineService {
@Autowired
    private Col_ExamineDao examineDao;

    @Override
    public boolean agree(Integer id) {
     examineDao.agree(id);
     return true;
    }

    @Override
    public void disagree(Integer id) {
        examineDao.disagree(id);
    }

    @Override
    public PageBean<All> selectByPage(int currentPage, int pageSize,String academyName) {

        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
//        查询当前页的数据
        academyName="%"+academyName+"%";
        List<All> rows = examineDao.selectBypage(begin, size,academyName);
//        查询总记录数
        int totalCount = examineDao.selectTotalCount(academyName);
//封装pageBean

        PageBean<All> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }
    @Override
    public PageBean<teacher> selectByPage2(int currentPage, int pageSize,String academyName) {

        int begin=(currentPage-1)*pageSize;
//        计算查询的条目数
        int size =pageSize;
//        查询当前页的数据
        academyName="%"+academyName+"%";
        List<teacher> rows = examineDao.selectBypage2(begin, size,academyName);
//        查询总记录数
        int totalCount = examineDao.selectTotalCount2();
//封装pageBean
        PageBean<teacher> pageBean=new PageBean<>();
        pageBean.setRows(rows);
        pageBean.setTotalCount(totalCount);
        return pageBean;
    }

    @Override
    public void cancle(Integer id) {
        examineDao.cancle(id);
    }
}
